package live.sidian.database.synchronizer;

import live.sidian.database.synchronizer.sync.structure.model.Database;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;

import javax.annotation.Resource;

@SpringBootApplication
public class SynchronizerApplication implements CommandLineRunner {
    @Bean
    @ConfigurationProperties(prefix = "dev.source")
    Database source() {
        return new Database();
    }

    @Bean
    @ConfigurationProperties(prefix = "dev.target")
    Database target() {
        return new Database();
    }

    @Resource
    Synchronizer synchronizer;

    public static void main(String[] args) {
        SpringApplication.run(SynchronizerApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
//        synchronizer.syncStructure(source(), target());
        synchronizer.syncData(source(), target(), null);
    }
}
